#include "instanceobj.h"
#include "nddjsonplugin.h"
#include <qsciscintilla.h>
#include <QWidget>
#include <QMenu>


extern std::function<QsciScintilla* (QWidget*)> s_getCurEdit;
extern std::function<bool(QWidget*, int, void*)> s_invokeMainFun;


InstanceObj::InstanceObj(QWidget* pNotepad, QMenu* pMenu, QString pluginFilePath) :QObject(pNotepad), m_nddJsonPlugin(nullptr),m_pluginFilePath(pluginFilePath)
{
	m_pNotepad = pNotepad;
	m_rootMenu = pMenu;
}

InstanceObj::~InstanceObj()
{

}

void InstanceObj::init()
{
	if (m_nddJsonPlugin == nullptr)
	{
		m_nddJsonPlugin = new NDDJsonPlugin(m_pNotepad, m_pluginFilePath, nullptr);
		m_nddJsonPlugin->setScintilla(s_getCurEdit, m_pNotepad);
	}
}
void InstanceObj::showJsonTable()
{
	init();
	m_nddJsonPlugin->showJsonTable();
}

void InstanceObj::formatJson()
{
	init();
	m_nddJsonPlugin->formattingJson();
}

void InstanceObj::compressJson()
{
	init();
	m_nddJsonPlugin->compressJson();
}

void InstanceObj::jsonViewSettings()
{
	init();
	m_nddJsonPlugin->jsonViewSettings();
}